create table "ProviderMedicationGroup"(
	"ProviderMedicationGroupId" serial primary key,
	"TagName" text,	
	"SpecializationId" int references "Specialization"("SpecializationId") default null,	
	"CreatedBy" int references "Account"("AccountId"),
	"CreatedDate" timestamp without time zone,
	"ModifiedBy" int references "Account"("AccountId"),
	"ModifiedDate" timestamp without time zone
);


CREATE TABLE "ProviderMedicationMaster" (
	"ProviderMedicationMasterId" serial primary key,
	"ProviderMedicationGroupId" int references "ProviderMedicationGroup"("ProviderMedicationGroupId"),
	"PharmacyProductId" int4 NULL,
	"Duration" int4 NOT NULL,
	"DurationType" varchar(10) NOT NULL,
	"IsMorning" bool NULL DEFAULT false,
	"IsAfternoon" bool NULL DEFAULT false,
	"IsNight" bool NULL DEFAULT false,
	"MorningDosage" text NULL,
	"AfternoonDosage" text NULL,
	"NightDosage" text NULL,
	"Dosage" int4 NOT NULL,
	"Instruction" text NULL
);

create table "ProviderMedicationMap"(
	"ProviderMedicationMapId" serial primary key,
	"ProviderId" int references "Provider"("ProviderId"),
	"Active" boolean default true,
	"CreatedBy" int references "Account"("AccountId"),
	"CreatedDate" timestamp without time zone,
	"ModifiedBy" int references "Account"("AccountId"),
	"ModifiedDate" timestamp without time zone
);

alter table "ProviderMedicationMap" add column "ProviderMedicationMasterId" int references "ProviderMedicationMaster"("ProviderMedicationMasterId");
